<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>事件处理</title>
</head>

<body>
    <!-- 准备好一个容器 -->
    <div id="test"></div>


    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>

    <script type="text/babel">  /*此处一定要写babel*/
        //创建组件
        class Demo extends React.Component {
            //创建容器
            myRef = React.createRef();
            myRef2 = React.createRef();

            showInfo = () => {
                alert(this.myRef.current.value)
            }

            showInfo2 = (event) => {
                //event.target 事件源 也就是input框
                alert(event.target.value)
            }


            render() {
                return (
                    <div>
                        <input ref={this.myRef} type="text" /><br />
                        <button onClick={this.showInfo}>点击提示输入数据</button>
                        <input onBlur={this.showInfo2}  type="text" /><br />
                    </div>
                )
            }
        }

        //渲染组件到页面
        ReactDOM.render(<Demo />, document.getElementById('test'));

    </script>
</body>

</html>